﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entity.Car_Rental;
using Entity;

namespace Data.Car_Rental
{
    public class Product_Property_RRepository : Car_RentalRepositoryBase, IProduct_Property_RRepository
    {

        #region IProduct_Property_RRepository 成员

        public IQueryable<Product_Property_R> GetDetailModel()
        {
            var linq = from data in this.GetModel()
                       join data2 in new ProductPropertyRepository().GetDetailModel() on data.ProductPropertyID equals data2.PropertyID
                       join data3 in new ProductRepository().GetModelForSite() on data.ProductID equals data3.ProductID
                       select new Product_Property_R_Ext
                       {
                           ProductID = data.ProductID,
                           ProductPropertyID = data.ProductPropertyID,
                           Product_Extend = data3,
                           ProductProperty_Extend = data2,
                           SortNumber = data.SortNumber,
                          
                       };
            return linq;
        }

        public PagedList<Product_Property_R> GetProduct_Property_R(VPredication vp, PagingParam pp)
        {
            var linq = this.GetDetailModel();
            return new PagedList<Product_Property_R>(linq, pp.PageIndex, pp.PageSize);
        }

        #endregion

        #region IRepository<Product_Property_R> 成员

        public void Update(Product_Property_R entity)
        {
            base.UpdateEntity(entity);
        }

        public void Update(IList<Product_Property_R> list)
        {
            base.UpdateEntity(list.Cast<EntityBase>().ToList());
        }

        public void Insert(Product_Property_R entity)
        {
            base.InsertEntity(entity);
        }

        public void Insert(IList<Product_Property_R> list)
        {
            base.InsertEntity(list.Cast<EntityBase>().ToList());
        }

        public Product_Property_R InsertGetIDENTITY(Product_Property_R entity)
        {
            base.InsertEntity(entity);
            return this.Find(entity.PrimaryKey);
        }

        public void Delete(Product_Property_R entity)
        {
            base.DeleteEntity(entity);
        }

        public void Delete(IList<Product_Property_R> list)
        {
            base.DeleteEntity(list.Cast<EntityBase>().ToList());
        }

        public IQueryable<Product_Property_R> GetModel()
        {
            return base.GetEntities<Product_Property_R>();
        }

        public Product_Property_R Find(params object[] keyValues)
        {
            return base.Find<Product_Property_R>(keyValues);
        }

        #endregion
    }
}
